home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_21.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  2KB  |  78 lines

  1. program GSDMO_21;
  2. {------------------------------------------------------------------------------
  3.                         DBase File and Structure Copying
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        06 February 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program demonstrates how dBase files and file structures may
  14.        be copied using Griffin Solutions units.
  15.  
  16.        The program creates (if necessary) and opens a dBase file and its
  17.        memo. It then copies the files to new file named GSDMO21A.DBF and
  18.        GSDMO21A.DBT.  Records will only be copied if they are valid (i.e.,
  19.        deleted records are ignored if SetDeletedOn, and SetFilterThru must
  20.        validate the record as well).  You can match the two files and see
  21.        that record 7 in GSDMO_21.DBF was not copied, because its deletion
  22.        flag was set before copying.
  23.  
  24.        Next, the file structure only is copied to GSDMO21B.DBF and DBT.
  25.        This is useful when the file structure must be preserved for future
  26.        use.
  27.  
  28.        New procedures/functions introduced are:
  29.  
  30.                  CopyTo
  31.                  CopyStructure
  32.  
  33. -------------------------------------------------------------------------------}
  34.  
  35. uses
  36.    GSOB_Var,
  37.    GSOB_Gen,
  38.    GSOBShel,
  39.    {$IFDEF WINDOWS}
  40.       WinCRT;
  41.    {$ELSE}
  42.       CRT;
  43.    {$ENDIF}
  44.  
  45. begin
  46.    ClrScr;
  47.  
  48.    if not FileExist('GSDMO_21.DBF') then
  49.  
  50.    begin
  51.       writeln('Creating GSDMO_21.DBF');
  52.       MakeTestData(4,'GSDMO_21', 20, true);      {Make a dBase IV file}
  53.       writeln('GSDMO_21.DBF Created');
  54.    end;
  55.  
  56.    SetDeletedOn;
  57.    Select(1);
  58.    Use('GSDMO_21');
  59.    go(7);
  60.    DeleteRec;                      {This record should not copy}
  61.    CopyTo('GSDMO21A');
  62.    CopyStructure('GSDMO21B');
  63.    select(2);
  64.    Use('GSDMO21A');
  65.    GoTop;
  66.    while not dEOF do
  67.    begin
  68.       writeln(FieldGet('LASTNAME'),' ',
  69.               FieldGet('FIRSTNAME'),'  ',
  70.               RecNo);
  71.       Skip(1);
  72.    end;
  73.    CloseDataBases;
  74. end.
  75.  
  76.  
  77.  
  78.